/*
 * @Description: 查看年审资料
 * @Author: Zzt
 * @Date: 2022-12-31 15:44:31
 * @LastEditTime: 2023-02-01 09:31:05
 */
import { Button, Descriptions, Input, Modal, Space, Table } from 'antd';
import { ColumnsType } from 'antd/lib/table';
import { byteConvert } from '@/utils';

const SawInspection = (props: any) => {
  const { visible, onClose, disabled, data } = props;

  const columns: ColumnsType = [
    {
      title: '序号',
      align: 'center',
      dataIndex: 'fileNo',
      key: 'fileNo'
    },
    {
      title: '附件名称',
      dataIndex: 'fileName',
      align: 'center',
      key: 'fileName',
      width: '30%'
    },
    {
      title: '格式',
      dataIndex: 'fileExt',
      align: 'center',
      key: 'fileExt'
    },
    {
      title: '附件大小',
      dataIndex: 'fileSize',
      align: 'center',
      key: 'fileSize',
      render: (size: number) => byteConvert(size)
    },
    {
      title: '状态',
      dataIndex: 'status',
      align: 'center',
      key: 'format'
    },
    {
      title: '操作',
      key: 'action',
      align: 'center',
      render: (_, record: any) => (
        <Space size="small">
          <Button size="small" type="link" href={record.fileUrl} target={'_blank'} download>
            下载
          </Button>
          <Button size="small" type="link" href={record.fileUrl} target={'_blank'}>
            浏览
          </Button>
        </Space>
      )
    }
  ];
  const onCancel = () => {
    onClose();
  };

  return (
    <>
      <Modal
        title="年检审核"
        visible={visible}
        width={600}
        destroyOnClose
        onCancel={onCancel}
        footer={[]}
      >
        <div>
          <Descriptions labelStyle={{ fontWeight: 'bold' }}>
            <Descriptions.Item label="年检名称" span={3}>
              {/* {detectionJobVO.name} */}
              {data?.name}
            </Descriptions.Item>
            <Descriptions.Item label="发送单位" span={3}>
              {/* {detectionJobVO.name} */}
              {data?.instructedUnitName}
            </Descriptions.Item>
            <Descriptions.Item label="发送人">{data?.operatorName}</Descriptions.Item>
          </Descriptions>
          <Descriptions labelStyle={{ fontWeight: 'bold' }} layout="vertical">
            <Descriptions.Item label="说明" span={3}>
              <Input.TextArea disabled value={data?.remark}></Input.TextArea>
            </Descriptions.Item>
            <Descriptions.Item label="附件" span={3}>
              <Table
                columns={columns}
                dataSource={data?.attachmentJsonDTOS}
                style={{ width: '100%' }}
                bordered={true}
                size={'small'}
              ></Table>
            </Descriptions.Item>
          </Descriptions>
        </div>
      </Modal>
    </>
  );
};
export default SawInspection;
